package com.huiquan.inspection.dao;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.huiquan.inspection.domain.Report;
import com.huiquan.analysis.domain.User;
import com.huiquan.framework.base.EnhancedBaseDao;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class ReportDao extends EnhancedBaseDao<Report> {

	@Resource(name = "sqlMapClient")
	private SqlMapClient sqlMapClient;

	public static final String space = "REPORT.";

	public ReportDao() {
		super(space);
	}

	public void updateDisable(Long id, Integer current, User user) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		param.put("current", current);
		param.put("userId", user.getUserId());
		param.put("userName", user.getRealName());
		this.update(space + "UPDATE_DISABLE", param, sqlMapClient);
	}

	public int retrieveSizeByName(String name) {
		Map<String, Object> param = new HashMap<>();
		param.put("name", name);
		Integer size = (Integer) this.object(space + "RETRIEVE_SIZE_BY_NAME", param, sqlMapClient);
		return size == null ? 0 : size;
	}
}
